//
//  MJChooseSexController.m
//  MJ
//
//  Created by qiaoBu on 2017/12/11.
//  Copyright © 2017年 lina. All rights reserved.
//

#import "MJChooseSexController.h"
#import "MJHomeViewController.h"

@interface MJChooseSexController ()

@property (nonatomic, copy) NSString *sexString;

@end

@implementation MJChooseSexController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navgationBar.hidden = YES ;
    self.view.backgroundColor = RGBColor(255,130,128);
    self.sexString = @"1";
    
    [self commonInit];
}
- (void)commonInit{
    
//    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//    [self.view addSubview:button];
//    [button mas_makeConstraints:^(MASConstraintMaker *make) {
//
//        make.left.mas_equalTo(self.view.mas_left).offset(0);
//        make.size.mas_equalTo(CGSizeMake(48, 48));
//        make.centerY.mas_equalTo(self.navgationBar.titleLabel);
//    }];
//     [button setImage:[UIImage imageNamed:@"arrow_back"] forState:UIControlStateNormal];
//    [button addTarget:self action:@selector(backButtonClick:) forControlEvents:UIControlEventTouchUpInside];
   
    
    
    UIView *manView = [[UIView alloc] init];
    [self.view addSubview:manView];
    [manView mas_makeConstraints:^(MASConstraintMaker *make) {
      
        make.right.mas_equalTo(self.view).offset(-(kScreenWidth-120*2)/3);
        make.width.mas_equalTo(120);
        make.height.mas_equalTo(160);
        make.centerY.mas_equalTo(self.view).offset(50);
    }];
    
    UIImageView *titleImageView = [[UIImageView alloc] init];
    [self.view addSubview:titleImageView];
    [titleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(self.view.mas_centerX);
//        make.height.mas_equalTo(35/1.8);
//        make.width.mas_equalTo(539/1.8);
        make.width.mas_equalTo(kScreenWidth - (kScreenWidth-120*2)/3*2);
        make.height.mas_equalTo((kScreenWidth - (kScreenWidth-120*2)/3*2)/539*35);
        make.bottom.mas_equalTo(manView.mas_top).offset(-165/2);
    }];
    titleImageView.image = [UIImage imageNamed:@"chooseTitle"];
    
    UIImageView *manImageView = [[UIImageView alloc] init];
    [manView addSubview:manImageView];
    [manImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.top.right.mas_equalTo(manView);
        make.width.height.mas_equalTo(manView.mas_width);
    }];
    manImageView.image = [UIImage imageNamed:@"boy"];
    
    UIImageView *manSexImage = [[UIImageView alloc] init];
    [manView addSubview:manSexImage];
    [manSexImage mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(manImageView.mas_bottom).offset(10);
        make.centerX.mas_equalTo(manView.mas_centerX);
        make.width.height.mas_equalTo(30);
    }];
    manSexImage.image = [UIImage imageNamed:@"man"];
    
    UIButton *manBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:manBtn];
    [manBtn mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.right.top.bottom.mas_equalTo(manView);
    }];
    manBtn.backgroundColor = [UIColor clearColor];
    
    
    UIView *womanView = [[UIView alloc] init];
    [self.view addSubview:womanView];
    [womanView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.left.mas_equalTo(self.view).offset((kScreenWidth-120*2)/3);
        make.width.height.top.mas_equalTo(manView);
    }];
    
    UIImageView *womanImageView = [[UIImageView alloc] init];
    [womanView addSubview:womanImageView];
    [womanImageView mas_makeConstraints:^(MASConstraintMaker *make) {

        make.left.top.right.mas_equalTo(womanView);
        make.width.height.mas_equalTo(womanView.mas_width);
    }];
    womanImageView.image = [UIImage imageNamed:@"girl"];

    UIImageView *womanSexImage = [[UIImageView alloc] init];
    [womanView addSubview:womanSexImage];
    [womanSexImage mas_makeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(womanImageView.mas_bottom).offset(10);
        make.centerX.mas_equalTo(womanView.mas_centerX);
        make.width.height.mas_equalTo(30);
    }];
    womanSexImage.image = [UIImage imageNamed:@"women"];

    UIButton *womanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:womanBtn];
    [womanBtn mas_makeConstraints:^(MASConstraintMaker *make) {

        make.left.right.top.bottom.mas_equalTo(womanView);
    }];
    womanBtn.backgroundColor = [UIColor clearColor];

    manBtn.tag = 100;
    womanBtn.tag = 200;

    [manBtn addTarget:self action:@selector(sexBtnClick:) forControlEvents:UIControlEventTouchUpInside];

    [womanBtn addTarget:self action:@selector(sexBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    
}
- (void)sexBtnClick:(UIButton *)button{
    
    if (button.tag == 100)
    {
    
        [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:MJ_Sex];
        [[NSUserDefaults standardUserDefaults] synchronize];
        
    }
    else
    {
        [[NSUserDefaults standardUserDefaults] setObject:@"2" forKey:MJ_Sex];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    MJHomeViewController *homeController = [[MJHomeViewController alloc] init];
    [self.navigationController pushViewController:homeController animated:YES];
}
//- (void)backButtonClick:(UIButton *)button{
//    
//    [self.navigationController popViewControllerAnimated:YES];
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
